package com.chinafree.business.controller;

import com.chinafree.business.model.param.JobParam;
import com.chinafree.business.model.queryCondition.JobQueryCondition;
import com.chinafree.business.model.result.JobResult;
import com.chinafree.business.service.JobService;
import com.chinafree.common.model.enumeration.ResponseCodeEnum;
import com.chinafree.common.model.request.RequestParameter;
import com.chinafree.common.model.response.BaseResponse;
import com.chinafree.common.model.response.EntityResponse;
import com.chinafree.common.model.response.ListPagingResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("job")
public class JobController extends BaseController {

    @Autowired
    private JobService jobService;

    @ApiOperation(value = "获得工作信息")
    @PostMapping("/getJobInfoById")
    private EntityResponse<JobResult> getJobInfoById(@RequestBody RequestParameter<Long> jobId) {
        JobResult jobResult = jobService.getJobInfoById(jobId.getBody());
        return new EntityResponse<>(ResponseCodeEnum.SUCCESS, "查询成功", jobResult);
    }


    @ApiOperation(value = "获得工作信息")
    @PostMapping("/getJobInfo")
    private EntityResponse<List<JobResult>> getJobInfo() {
        List<JobResult> jobResult = jobService.getJobInfo();
        return new EntityResponse<>(ResponseCodeEnum.SUCCESS, "查询成功", jobResult);
    }

    @ApiOperation(value = "更新工作信息")
    @PostMapping("/update")
    private BaseResponse update(@RequestBody RequestParameter<JobParam> jobParamRequestParameter) {
        jobService.update(jobParamRequestParameter.getBody());
        return BaseResponse.success();
    }


    @ApiOperation(value = "插入工作信息")
    @PostMapping("/insert")
    private BaseResponse insert(@RequestBody RequestParameter<JobParam> jobParamRequestParameter) {
        jobService.insert(jobParamRequestParameter.getBody());
        return BaseResponse.success();
    }

    @ApiOperation(value = "删除工作信息")
    @PostMapping("/delete")
    private BaseResponse delete(@RequestBody RequestParameter<Long> requestParameter) {
        jobService.delete(requestParameter.getBody());
        return BaseResponse.success();
    }


    @ApiOperation(value = "工作批量查询")
    @PostMapping("/queryJobPage")
    public ListPagingResponse<JobResult> queryJobPage(@RequestBody RequestParameter<JobQueryCondition> jobQueryConditionRequestParameter) {
        return jobService.queryUserPage(jobQueryConditionRequestParameter.getBody());
    }




}
